#include <REGX52.H>
#include "LCD1602.h"
#include "Delay.h"
#include "Timer0.h"

unsigned char hour=23,min=56,sec=56;
void main()
{	
	LCD_Init();
	LCD_ShowString(1,1,"Clock:");
	LCD_ShowString(2,3,":  :");
	Timer0Init();
	while(1)
	{
		LCD_ShowNum(2,1,hour,2);
		LCD_ShowNum(2,4,min,2);
		LCD_ShowNum(2,7,sec,2);
	}
}

void Timer0_Rountine(void) interrupt 1
{
	static unsigned int TimeCount=0;
	TL0 = 0x66;	
	TH0 = 0xFC;	
	TimeCount++;
	if(TimeCount>=1000)
	{
		TimeCount=0;
		sec++;
		if(sec>=60)
		{
			sec=0;
			min++;
			if(min>=60)
			{
				min=0;
				hour++;
				if(hour>=24)
				{
					hour=0;min=0;sec=0;
				}
			}
		}
	}
}